package com.zl.zsk.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zl.zsk.constant.RetCode;
import com.zl.zsk.pojo.vo.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author lxb
 * @version 1.0.0
 * @desc:
 * @date 2020-03-16 10:20
 */
public class SecurityResponse {
    public static void getCommonResponse(HttpServletResponse response,Result result) throws IOException {
        response.setStatus(200);
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json; charset=utf-8");
        PrintWriter printWriter = response.getWriter();
        ObjectMapper objectMapper = new ObjectMapper();
        String s = objectMapper.writeValueAsString(result);
        printWriter.write(s);
    }
}
